<?php

use IDock\Printer\NonCar\NonCarUnderwritingPrinter;
use IDock\Printer\ProposalStatusPrinter;
use IDock\Visitor\EPolicyDownloadVisitor;
use IDock\Visitor\NonCar\NonCarInquiryVisitor;
use IDock\Visitor\NonCar\NonCarProductListVisitor;
use IDock\Visitor\NonCar\NonCarProductVisitor;
use IDock\Visitor\PolicyInfoVisitor;
use IDock\Visitor\PolicyPaymentVisitor;
use IDock\Visitor\Premium\PremiumCarTaxVisitor;
use IDock\Visitor\Premium\PremiumChargingPileVisitor;
use IDock\Visitor\Premium\PremiumCoverageVisitor;
use IDock\Visitor\Premium\PremiumExtInfoVisitor;
use IDock\Visitor\Premium\PremiumInquiryVisitor;
use IDock\Visitor\Premium\PremiumNoCarVisitor;
use IDock\Visitor\Premium\PremiumPolicyVisitor;
use IDock\Visitor\Premium\PremiumRelationVisitor;
use IDock\Visitor\Premium\PremiumUnderwritingVisitor;
use IDock\Visitor\Premium\PremiumVehicleVisitor;
use IDock\Visitor\ProposalRecallVisitor;
use IDock\Visitor\ProposalStatusVisitor;
use IDock\Visitor\RenewalInquiryVisitor;
use IDock\Visitor\UnderwritingRecallVisitor;
use IDock\Visitor\UploadFileVisitor;
use IDock\Visitor\VehicleActualValueVisitor;
use IDock\Visitor\VehicleModelVisitor;

require_once('./vendor/autoload.php');

$IDock = new \IDock\IDock\IDock();

$TPBXConfig = [
    'gateway' => '*************',
    'logsDir' => '*************',
    'timeout' => '*************',
    'chalCode' => '*************',
    'userCode' => '*************',
    'productCode' => '*************',
    'planCode' => '*************',//燃油车
//    'planCode' => 'PLAN003',//新能源

    'proxy' => '118.123.247.195:45131',
];

require_once('config.php');

$IDock->setBean('TPBX', $TPBXConfig);


global $testResponse;

$shortName = 'TPBX';
//$shortName = 'ACIC';


$vin = 'LZWADAGA8HF791218';
$engineNo = '8H73121140';
$licenseNo = '川A9K7R5';
$firstRegisterDate = '2018-05-04';
$vehicleModel = '东南DN7151M5T轿车';

$orderNo = 'D20230807070000002041570f983d914';//

$biStartData = '2023-08-10 00:00:00';
$ciStartData = '2023-09-24 00:00:00';
$biEndData = '2024-08-10 00:00:00';
$ciEndData = '2024-09-23 23:58:59';

//$engineNo = 'SVW71217DN';
//$vin = 'LSVGZ6183J2037364';
global $testResponse;
$testResponse = '';


try {


//续保查询接口
    if (0) {
        //续保查询接口
        $renewalInquiryVisitor = new RenewalInquiryVisitor();
        //车架号
        $renewalInquiryVisitor->vin = $vin;
        //发动机号
        $renewalInquiryVisitor->engineNo = $engineNo;
        //车牌号
        $renewalInquiryVisitor->licenseNo = $licenseNo;
        $renewalInquiryVisitor->argc['type'] = 1;
$testResponse = '{"code": "0000","msg": "成功","data": {"head": {"requestType": "V091","account": "15520756896_guangdong","password": "666666"},"bizApply": {"applyNo": "1000109000015941059","policyNo": "21130000109240000004","totalStandardPremium": "1502.77","totalActualPremium": "1105.66","stampTax": "","totalRatioOD": "","totalRatioTP": "","totalRatioTHEFT": "","totalRatioOTHER": "","fixedSpecialPromise": "","alterableSpecialPromise": "1、尊敬的客户：您本次是通过兼业代理渠道购买的车辆保险，兼业代理机构名称：石家庄营业总部分销商支持三部，联系电话：15716391396。如有异议，请拨打公司客户服务电话95550。","lastPolicyNo": "","effectiveDate": "20230806000000","expireDate": "20240805235959","signTime": "20240102","status": "","payStatus": "1","paymentNo": "22065761","renewalFlag": "","isRenewal": "0","underwriteMark": "2","commissionChargeProportion": "0.00"},"tpfApply": {"applyNo": "1000105000015941058","policyNo": "21130000105240000005","totalStandardPremium": "950","totalActualPremium": "950.00","stampTax": "","renewalFlag": "","isRenewal": "0","totalRatioOD": "","totalRatioTP": "","totalRatioTHEFT": "","totalRatioOTHER": "","fixedSpecialPromise": "","alterableSpecialPromise": "1、尊敬的客户：您本次是通过兼业代理渠道购买的车辆保险，兼业代理机构名称：石家庄营业总部分销商支持三部，联系电话：15716391396。如有异议，请拨打公司客户服务电话95550。","lastPolicyNo": "","effectiveDate": "20230806000000","expireDate": "20240805235959","signTime": "20240102161057","status": "","payStatus": "1","paymentNo": "22065760","underwriteMark": "2","commissionChargeProportion": "0.00"},"vehicle": {      "vehicleLicenceCode": "黑AK34L5",      "vehicleFrameNo": "LK7DS56X97754999J",      "engineNo": "LL6758KLK547",      "firstRegisterDate": "20210722",      "weight": "1.515",      "airbagCount": "",      "priceType": "04",      "purchasePrice": "28500",      "theftProof": "5",      "importFlag": "",      "vehicleType": "1",      "vehicleStyle": "K33",      "autoModelCode": "CAAAED0016",  "modelCode": "BCADYVUA0014",      "vehicleBrand": "长安",      "isMotorcade": "0",      "vehicleSeats": "5",      "fuelType": "0",      "transferDate": "",      "fleetNo": "",      "transmissionType": "",      "usageAttributeCode": "1",      "autoModelChnName": "长安SC6361J",      "licenseTypeCode": "2",      "ecdemicVehicleFlag": "1",      "loanVehicleFlag": "",      "exhaustCapability": "1.012",      "vehicleTonnages": "0.000",      "specialCarFlag": "",      "vehicleCertificateNo": "",      "appointAreaCode": "",      "maker": "",      "power": "39",      "ownershipAttributeCode": "1",      "vehicleCertificateDate": "",      "vehicleCertificateType": "",      "runCardCertificateDate": "20210722"    },        "insured": {"personType": "1",      "person": {        "address": "山东省沂南县花山路61号",        "position": "",        "certificateNo": "362522199805190017",        "birthday": "19980519",        "personnelName": "饶呈宇",        "postcode": "000000",        "gender": "M",        "effectedDate": "",        "expiredDate": "",        "certType": "0",        "personType": "",        "certificateType": "1",        "mobileTelephone": "13133700519",        "email": "343277846@qq.com","teleNoOwnerIsSelfFlag": "1",        "phoneOwnerCertiNo": "","homeProvinceCode": "","homeCityCode": "","homeAreaCountyCode": "",        "phoneOwnerName": ""      }    },    "applicant": {"personType": "1",        "person": {          "address": "山东省沂南县花山路61号",          "position": "",          "certificateNo": "362522199805190017",          "birthday": "19980519",          "personnelName": "饶呈宇",          "postcode": "000000",          "gender": "M",          "effectedDate": "",          "expiredDate": "",          "certType": "0",          "personType": "",          "certificateType": "1",          "mobileTelephone": "13133700519",          "email": "343277846@qq.com",  "homeProvinceCode": "",  "homeCityCode": "",  "homeAreaCountyCode": "","teleNoOwnerIsSelfFlag": "1","phoneOwnerCertiNo": "","phoneOwnerName": ""        }    },    "vehicleOwner": {   "personType": "1",          "person": {          "address": "山东省沂南县花山路61号",          "position": "",          "certificateNo": "362522199805190017",          "birthday": "19980519",          "personnelName": "饶呈宇",          "postcode": "000000",          "gender": "M",          "effectedDate": "",          "expiredDate": "",          "certType": "0",          "personType": "",          "certificateType": "1",          "mobileTelephone": "13133700519",          "email": "343277846@qq.com",  "homeProvinceCode": "",  "homeCityCode": "",  "homeAreaCountyCode": "",  "teleNoOwnerIsSelfFlag": "1",          "phoneOwnerCertiNo": "",          "phoneOwnerName": ""        }      },    "coverageList":[        {            "coverageCode":"AOD",            "insuredAmount":"23541",            "allAmount":"23541",            "deductible":"",            "deductionRate":"0","subsidiary":"0",    "totalNetPremium":"439.64",            "totalActualPremium":"466.02","serviceNum":"","mileage":"",                "setMeal":""        }      ,            {            "coverageCode":"ATP",            "insuredAmount":"2000000",            "allAmount":"0",            "deductible":"",            "deductionRate":"0","subsidiary":"0",    "totalNetPremium":"572.52",            "totalActualPremium":"606.87","serviceNum":"","mileage":"",                "setMeal":""        }      ,            {            "coverageCode":"STORRS",            "insuredAmount":"0",            "allAmount":"0",            "deductible":"",            "deductionRate":"0","subsidiary":"0",    "totalNetPremium":"0.00",            "totalActualPremium":"0.00","serviceNum":"7","mileage":"",                "setMeal":""        }      ,            {            "coverageCode":"ATPDUOM",            "insuredAmount":"200000",            "allAmount":"0",            "deductible":"",            "deductionRate":"0","subsidiary":"0",    "totalNetPremium":"30.92",            "totalActualPremium":"32.77","serviceNum":"","mileage":"",                "setMeal":""        }      ,            {            "coverageCode":"TPF",            "insuredAmount":"200000",            "allAmount":"0",            "deductible":"",            "deductionRate":"0","subsidiary":"0",    "totalNetPremium":"896.23",            "totalActualPremium":"950.00","serviceNum":"","mileage":"",                "setMeal":""        }          ], "vehicleTax": {"taxConditionCode": "T","personCert": "362522199805190017","deductionDueCode": "","deductionDueType": "","deductionDueProportion": "","deduction": "","freeNo": "","vehicleTaxAmountThis": "360","vehicleTaxAmountLast": "0","vehicleTaxAmount": "360","lateDay": "0","lateFeeAmount": "0","taxAmountFlag": "1","calcTaxFlagName": "2","startDate": "20240101","endDate": "20241231","certDepartmentName": "","certificateDate": "","steerCardVehicleType": "K002","lastYearEndDate": "","payNo": "","payFreeState": ""}}}';
        $response = $IDock->renewalInquiry($shortName, $renewalInquiryVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var $printer \IDock\Printer\RenewalInquiryPrinter
         */
        $printer = $response->getPrinter();
//        var_dump($printer->toArray());
        exit;
    }

//车辆车型查询接口
    if (0) {
        //车辆车型查询接口
        $vehicleModelVisitor = new VehicleModelVisitor();
        //车架号
        $vehicleModelVisitor->vin = $vin;
        //$vehicleModelVisitor->vin = '';
        //发动机号
        $vehicleModelVisitor->engineNo = $engineNo;
        //车牌号
        $vehicleModelVisitor->licenseNo = $licenseNo;
        //初登时间
//        $vehicleModelVisitor->firstRegisterDate = $firstRegisterDate;
        //车型编码
        $vehicleModelVisitor->vehicleModel = $vehicleModel;

        $response = $IDock->vehicleModel($shortName, $vehicleModelVisitor);
        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var $printer \IDock\Printer\VehicleModelPrinter
         */
        $printer = $response->getPrinter();
        if($printer) var_dump($printer->toArray());
        exit;
    }

//车辆实际价格
    if (0) {
        //车辆实际价格
        $vehicleActualValueVisitor = new VehicleActualValueVisitor();
        $vehicleActualValueVisitor->startDate = $biStartData;
        $vehicleActualValueVisitor->firstRegisterDate = $firstRegisterDate;
        //车辆价格
        $vehicleActualValueVisitor->vehiclePrice = '54800';
        //能源类型
        $vehicleActualValueVisitor->energyType = 'E01';
        //是否新能源
        $vehicleActualValueVisitor->isNewEnergy = false;
        //使用性质
        $vehicleActualValueVisitor->useNatureCode = '01';
        //车辆用途
        $vehicleActualValueVisitor->causeType = '001';
        //车辆种类
        $vehicleActualValueVisitor->carKindCode = '100';
        //座位数
        $vehicleActualValueVisitor->vehicleSeat = '5';
        //荷载质量
        $vehicleActualValueVisitor->vehicleTonnage = '0';

        $response = $IDock->vehicleActualValue($shortName, $vehicleActualValueVisitor);
        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var $printer \IDock\Printer\VehicleActualValuePrinter
         */
        $printer = $response->getPrinter();
        var_dump($printer->toArray());
        exit;
    }

//询价前置
//保费计算
//核保
    if (1) {

        /**
         * 询价主信息
         */
        $premiumInquiryVisitor = new PremiumInquiryVisitor();
        //商业险起保日期
        $premiumInquiryVisitor->biStartData = $biStartData;
        //商业险终保日期
        $premiumInquiryVisitor->biEndData = $biEndData;
        //交强险起保日期
        $premiumInquiryVisitor->ciStartData = $ciStartData;
        //交强险终保日期
        $premiumInquiryVisitor->ciEndData = $ciEndData;
        //商业险即时生效
        $premiumInquiryVisitor->biEffectFlag = false;
        //交强险即时生效
        $premiumInquiryVisitor->ciEffectFlag = false;

        $premiumInquiryVisitor->isNewEnergy = true;

        /**
         * 车辆信息
         */
        $premiumVehicleVisitor = new PremiumVehicleVisitor();
        //是否新车
        $premiumVehicleVisitor->isNewVehicle = '1';
        //车架号
        $premiumVehicleVisitor->vin = $vin;
        //发动机号
        $premiumVehicleVisitor->engineNo = $engineNo;
        //车牌号
        $premiumVehicleVisitor->licenseNo = $licenseNo;
        //初登时间
        $premiumVehicleVisitor->firstRegisterDate = $firstRegisterDate;
        //过户时间
        $premiumVehicleVisitor->transferDate = '';
        //是否过户车
        $premiumVehicleVisitor->isTransfer = '0';
        //发证时间
        $premiumVehicleVisitor->issueDate = '';
        //车型编码
        $premiumVehicleVisitor->vehicleModel = $vehicleModel;
        //车型编码代码
        $premiumVehicleVisitor->vehicleModelCode = 'DZABJD0007';
        //$premiumVehicleVisitor->vehicleModelCode = 'BTYOSPUB0014';
        //车型名称
        $premiumVehicleVisitor->vehicleName = '丰田TV7152X轿车';
        //车价
        $premiumVehicleVisitor->vehiclePrice = '85535';
        //车价含税
        $premiumVehicleVisitor->vehiclePriceTax = '85535';
        //协商价格
        $premiumVehicleVisitor->actualValue = '82968.95';
        //座位数
        $premiumVehicleVisitor->vehicleSeat = '5';
        //使用性质
        $premiumVehicleVisitor->useNatureCode = '01';
        //所属性质
        $premiumVehicleVisitor->attachNature = '01';
        //车辆用途
        $premiumVehicleVisitor->causeType = '001';
        //车辆种类
        $premiumVehicleVisitor->carKindCode = '100';
        //能源类型代码
        $premiumVehicleVisitor->energyTypeCode = 'E01';
        //号牌颜色代码
        $premiumVehicleVisitor->licenseColorCode = '01';
        //号牌种类代码
        $premiumVehicleVisitor->licenseTypeCode = '02';
        //交管车辆类型代码
        $premiumVehicleVisitor->vehicleStyleCode = 'K33';
        //功率
        $premiumVehicleVisitor->power = '79.0';
        //排量
        $premiumVehicleVisitor->vehicleExhaust = '1.496';
        //整备质量
        $premiumVehicleVisitor->wholeWeight = '10.2';
        //荷载质量
        $premiumVehicleVisitor->vehicleTonnage = '0.0';
        //进口标识
        $premiumVehicleVisitor->vehicleImport = 'I2';
        //是否能源车
        $premiumVehicleVisitor->isNewEnergy = true;
        //纯电续航里程(公里)
        $premiumVehicleVisitor->pureRange = '';
        //车辆来历凭证编号
        $premiumVehicleVisitor->carCertificateNo = '';
        //开具车辆来历凭证所载日期
        $premiumVehicleVisitor->carCertificateDate = '';
        //车辆来历凭证种类代码
        $premiumVehicleVisitor->carCertificateType = '';

        /**
         * 关系人
         */
        $premiumRelationVisitor = new PremiumRelationVisitor();
        //姓名
        $premiumRelationVisitor->name = '廖皓';
        //联系方式
        $premiumRelationVisitor->mobile = '13550217453';
        //类型
        $premiumRelationVisitor->typeCode = 'R1';
        //证件类型
        $premiumRelationVisitor->certificateTypeCode = '01';
        //证件号码
        $premiumRelationVisitor->certificateNo = '51390219960714105X';
        //地址
        $premiumRelationVisitor->address = '四川省成都市龙泉驿区龙泉车城西一路185号1栋1单元20楼2001号';
        //邮箱
        $premiumRelationVisitor->email = '18982272991@qq.com';
        //证件有效期
        $premiumRelationVisitor->certificateStartDate = '2000-01-01';
        //证件失效期
        $premiumRelationVisitor->certificateEndDate = '2050-01-01';

        /**
         * 缴税信息
         */
        $premiumCarTaxVisitor = new PremiumCarTaxVisitor();
        //缴税内心
        $premiumCarTaxVisitor->taxTypeCode = 'T01';
        //纳税人姓名
        $premiumCarTaxVisitor->taxpayerName = '樊鑫';
        //纳税人证件类型
        $premiumCarTaxVisitor->taxpayerCertificateTypeCode = '01';
        //纳税人证件号码
        $premiumCarTaxVisitor->taxpayerCertificateNo = '51390219960714105X';
        //纳税人电话
        $premiumCarTaxVisitor->taxpayerPhone = '13550217453';
        //纳税起期
        $premiumCarTaxVisitor->taxStartDate = '2023-08-10 00:00:00';
        //纳税止期
        $premiumCarTaxVisitor->taxEndDate = '2024-08-09 23:59:59';
        //减免税方案代码
        $premiumCarTaxVisitor->taxReductionCode = '';
        //减免税原因代码
        $premiumCarTaxVisitor->taxReductionReasonCode = '';
        //税务机关名称
        $premiumCarTaxVisitor->taxDepartment = '';
        //税务机关代码
        $premiumCarTaxVisitor->taxDepartmentCode = '';
        //开具完税凭证地区代码
        $premiumCarTaxVisitor->taxPaidAreaCode = '';
        //完税凭证填发日期
        $premiumCarTaxVisitor->taxDocumentDate = '';
        //减免比例 百分比
        $premiumCarTaxVisitor->taxFreeRate = '';
        //减税金额 元
        $premiumCarTaxVisitor->taxExemption = '';
        //减免完税凭证号
        $premiumCarTaxVisitor->taxDocumentNumber = '';

        //险种

        //
        $premiumCoverageVisitor = new PremiumCoverageVisitor();
        $premiumCoverageVisitor->coverageCode = 'C01001';
        $premiumCoverageVisitor->amount = '200000';

//        $premiumCoverageVisitor1 = new PremiumCoverageVisitor();
//        $premiumCoverageVisitor1->coverageCode = 'C05001';
//        $premiumCoverageVisitor1->amount = '40000';
//        $premiumCoverageVisitor1->unitAmount = '10000';
////        $premiumCoverageVisitor1->deductionRate = '5';
////
//        $premiumCoverageVisitor2 = new PremiumCoverageVisitor();
//        $premiumCoverageVisitor2->coverageCode = 'C03001';
//        $premiumCoverageVisitor2->amount = '1000000';
////        $premiumCoverageVisitor2->deductionRate = '5';
//
//        $premiumCoverageVisitor3 = new PremiumCoverageVisitor();
//        $premiumCoverageVisitor3->coverageCode = 'C02001';
//        $premiumCoverageVisitor3->amount = '109409.8';


        //新能源充电桩信息
        $premiumChargingPileVisitor = new PremiumChargingPileVisitor();

        $premiumChargingPileVisitor->seqNo = '1';
        //充电桩类型
        $premiumChargingPileVisitor->chargingPileKind = 'PK1';
        //充电桩安装地点类型
        $premiumChargingPileVisitor->chargingPileAddressType = 'PA1';
        //充电桩使用年限
        $premiumChargingPileVisitor->chargingPileYearLimit = 'PY1';
        //充电桩编码
        $premiumChargingPileVisitor->chargingPileCode = '123456';
        //充电桩型号
        $premiumChargingPileVisitor->chargingPileType = 'BCS100500';
        //充电桩地址
        $premiumChargingPileVisitor->chargingPileAddress = '地面充电桩';
        //损失保险保额
        $premiumChargingPileVisitor->lossAmount = '';
        //责任保险保额
        $premiumChargingPileVisitor->liabilityAmount = '10000';

        /**
         * 拓展信息
         */
        $premiumExtInfoVisitor = new PremiumExtInfoVisitor();
        //验车情况
        $premiumExtInfoVisitor->carCheckCode = 'CS3';//已验
        //免验原因
        $premiumExtInfoVisitor->carCheckReasonKind = '';
        //验车人
        $premiumExtInfoVisitor->carChecker = '张三';
        //验车日期
        $premiumExtInfoVisitor->carCheckDate = '2023-08-02';
        //验车地点
        $premiumExtInfoVisitor->carAddress = '';
        //是否送修
        $premiumExtInfoVisitor->isMonopoly = '0';
        //送修代码
        $premiumExtInfoVisitor->repairCode = '';
        //送修名称
        $premiumExtInfoVisitor->repairName = '';
        //自主定价系数
        $premiumExtInfoVisitor->selfPricingFactor = '';
        //自主核保系数
        $premiumExtInfoVisitor->underwritingFactor = '';
        //期望折扣
        $premiumExtInfoVisitor->expectedDiscount = '';
        //是否贷款车
        $premiumExtInfoVisitor->isLoanCar = '';
        //贷款机构名称
        $premiumExtInfoVisitor->loanOrg = '';

        //珠峰拓展

        $premiumExtInfoVisitor->argc['orderNo'] = 'C20231201110525912000207270';
        $premiumExtInfoVisitor->argc['businessNo'] = 'HX202312011105255951';


        //添加车辆信息
        $premiumInquiryVisitor->setVehicleVisitor($premiumVehicleVisitor);
        //添加投保人
        $premiumInquiryVisitor->setApplicantVisitor($premiumRelationVisitor);
        //添加被保人
        $premiumInquiryVisitor->setInsuredVisitor($premiumRelationVisitor);
        //添加车主
        $premiumInquiryVisitor->setOwnerVisitor($premiumRelationVisitor);
        //车船税
        $premiumInquiryVisitor->setCarTaxVisitor($premiumCarTaxVisitor);

        /**
         * 非车列表
         */
        $nonCarInquiryVisitor = new NonCarInquiryVisitor();
        ////投保份数
        //$nonCarInquiryVisitor->setApplicantVisitor($premiumInquiryVisitor->getApplicantVisitor());
        ////产品代码
        $product = new NonCarProductVisitor();
        $product->productCode = '1234';
        $product->planCode = 'plan1';
        $nonCarInquiryVisitor->nonCarListAppend($product);

        //险种添加
//        $premiumInquiryVisitor->coverageVisitorAppend($premiumCoverageVisitor1);
//        $premiumInquiryVisitor->coverageVisitorAppend($premiumCoverageVisitor2);
//        $premiumInquiryVisitor->coverageVisitorAppend($premiumCoverageVisitor3);
        $premiumInquiryVisitor->coverageVisitorAppend($premiumCoverageVisitor);
        //新能源充电桩
//        $premiumInquiryVisitor->chargingPileVisitorAppend($premiumChargingPileVisitor);
        //拓展信息
        $premiumInquiryVisitor->setExtInfoVisitor($premiumExtInfoVisitor);
        //非车信息
        $premiumInquiryVisitor->setNonCarInquiryVisitor($nonCarInquiryVisitor);
        $premiumInquiryVisitor->setNonCarUnderwritingVisitor($nonCarInquiryVisitor);

        $premiumInquiryVisitor->fileAppend('1','1212','');
        //询价前置
//        $response = $IDock->preInquiry($shortName, $premiumInquiryVisitor);
//        var_dump($response->isSuccess());
//        var_dump($response->getError());
//        /**
//         * @var $printer \IDock\Printer\preInquiryPrinter;
//         */
//        $printer = $response->getPrinter();
//        var_dump($printer->toArray());
//        exit;

//        //询价
//        $response = $IDock->premiumInquiry($shortName, $premiumInquiryVisitor);
//        var_dump($response->isSuccess());
//        var_dump($response->getError());
//
//        /**
//         * @var $printer \IDock\Printer\Premium\PremiumInquiryPrinter;
//         */
//        $printer = $response->getPrinter();
//        if ($printer) {
//            var_dump($printer->toArray());
//        }
//
//        exit;

        /**
         * 核保信息
         */
        $premiumUnderwritingVisitor = new PremiumUnderwritingVisitor();
        $premiumUnderwritingVisitor->biInquiryNo = '';
        $premiumUnderwritingVisitor->ciInquiryNo = '';

        $premiumUnderwritingVisitor->agreement = [];

        $premiumInquiryVisitor->setUnderwritingVisitor($premiumUnderwritingVisitor);
        //核保
        $response = $IDock->underwriting($shortName, $premiumInquiryVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());
        var_dump($response->printer->noCarUnderwritingPrinter);
        /**
         * @var $printer \IDock\Printer\PremiumUnderwritingPrinter;
         */
        $printer = $response->getPrinter();

        if ($printer) var_dump($printer->toArray());
        exit;
    }

//支付
    if (0) {
        $policyPaymentVisitor = new PolicyPaymentVisitor();
        $policyPaymentVisitor->inquiryNo = '599510803602023000184';
        $policyPaymentVisitor->biInquiryNo = '';
        $policyPaymentVisitor->ciInquiryNo = '599510803602023000184';
        $response = $IDock->policyPayment($shortName, $policyPaymentVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());
        /**
         * @var $printer \IDock\Printer\PolicyPaymentPrinter
         */
        $printer = $response->getPrinter();

        var_dump($printer->toArray());
        exit;
    }

//影像资料上传
    if (0) {
        $uploadFileVisitor = new UploadFileVisitor();
        $uploadFileVisitor->inquiryNo = 'M232010136320230000010';
        $uploadFileVisitor->biInquiryNo = 'T232010080820230000014';
        $uploadFileVisitor->ciInquiryNo = 'T232010080120230000010';

        $appType = 'G_HX';//一级代理和二级代理
        $orgNum = '07000002';//出单机构
        $oprId = '00000020';//操作员编码
        $upType = '2';//上传方式 1（文件流），2（ftp）
        $imageList = [
            [
                'imgName' => 'test111.jpg',//要求英文
//                'base64Img' => base64_encode(file_get_contents(__DIR__ . '/test.jpg')),//图片base64编码
                'filedSuffix' => 'jpg',//文件后缀
                'filedPath' => 'https://p0.itc.cn/q_70/images03/20220512/77ed76720a1f40ef94948761dda05655.jpeg',//图片地址 ftp模式必传
            ],
        ];
        foreach ($imageList as $val){
            $uploadFileVisitor->fileAppend('10017',$val['filedPath'],'');
        }
        $uploadFileVisitor->argc['isNewCar'] = 1;
        $uploadFileVisitor->argc['platOrderNo'] = 'C20230816095559578000106043';

        $response = $IDock->UploadFile($shortName, $uploadFileVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var  $printer \IDock\Printer\UploadFilePrinter
         */
        $printer = $response->getPrinter();

        if(!empty($printer)) var_dump($printer->toArray());
        exit;
    }

//投保单查询
    if (0) {
        $proposalStatusVisitor = new ProposalStatusVisitor();

        $proposalStatusVisitor->inquiryNo = '599510803602023000279';
        $proposalStatusVisitor->biInquiryNo = '';
        $proposalStatusVisitor->ciInquiryNo = '599510803602023000279';
        $proposalStatusVisitor->argc['orderNo'] = 'NSNL202403081715380484';
        $response = $IDock->proposalStatus($shortName, $proposalStatusVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());

        /*** @var $printer ProposalStatusPrinter; */
        $printer = $response->getPrinter();

        var_dump($printer);
        exit;
    }

//撤单
    if (0) {
        $proposalRecallVisitor = new ProposalRecallVisitor();

        $proposalRecallVisitor->inquiryNo = '599510803682023000036';
        $proposalRecallVisitor->biInquiryNo = '';
        $proposalRecallVisitor->ciInquiryNo = '599510803682023000036';
        $proposalRecallVisitor->reason = '客户注销';
        $proposalRecallVisitor->argc['orderNo'] = 'NSYZ202402211109289919';

        $response = $IDock->proposalRecall($shortName, $proposalRecallVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var $printer \IDock\Printer\ProposalRecallPrinter
         */
        $printer = $response->getPrinter();
        var_dump($printer);
        exit;
    }

//核保撤单
    if (0) {
        $underwritingRecallVisitor = new UnderwritingRecallVisitor();

        $underwritingRecallVisitor->inquiryNo = 'M232010136320230000010';
        $underwritingRecallVisitor->biInquiryNo = 'T232010080820230000014';
        $underwritingRecallVisitor->ciInquiryNo = 'T232010080120230000010';
        $underwritingRecallVisitor->reason = '投保注销';
        $underwritingRecallVisitor->argc['OrgCode'] = '51080503';


        $underwritingRecallVisitor->argc['platOrderNo'] = 'C20230816095559578000106043';

        $response = $IDock->underwritingRecall($shortName, $underwritingRecallVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());

        /**
         * @var $printer \IDock\Printer\UnderwritingRecallPrinter
         */
        $printer = $response->getPrinter();
        if(!empty($printer)) var_dump($printer->toArray());
        exit;

    }

//电子保单下载
    if (0) {
        $EPolicyDownloadVisitor = new EPolicyDownloadVisitor();

        $EPolicyDownloadVisitor->policyNo = '2070003562023000259';
        $EPolicyDownloadVisitor->argc['orderNo'] = 'P435019C052400000014140';
//$testResponse = '{    "code": "0000",    "msg": "",    "data": {        "head": {            "requestType": "V113",            "account": "",            "password": ""        },        "basePart": {            "printUrl": "aHR0cHM6Ly91YXRzLmF4YS5jbi9maWxlU2VydmVyL2hleFRpY2tldEZpbGVWaWV3LmRvP2Z0aWNrZXQ9NURGRkU0Qjc5QjEyMkU0RTM4NTA5QzQxQkVFMDM5MDQzQkQwMzQ3MTQ2MDJBMTVCNjkzMDFFQkMyMDExNjBBMjM5QzkxQ0I1RjcyQTA5NzY3N0I3MDg2OTA5Qzk2Q0VDQUU2NUI0QzFCREY3Qzc3NDRGRUU2RDA0QkJEOUFEOTY="        }    }}';
        $response = $IDock->EPolicyDownload($shortName, $EPolicyDownloadVisitor);

        var_dump($response->isSuccess());
        var_dump($response->getError());
        var_dump($response->getPrinter()->data);


        /**
         * @var $printer \IDock\Printer\EPolicyDownloadPrinter
         */
        $printer = $response->getPrinter();
        var_dump($printer->finish);
        exit;
    }

//保单详情
    if (0) {
        $policyInfoVisitor = new PolicyInfoVisitor();

        $policyInfoVisitor->policyNo = 'C20230816095559578000106043';
        $policyInfoVisitor->argc['platOrderNo'] = 'C20230816095559578000106043';
        $response = $IDock->policyInfo($shortName, $policyInfoVisitor);
        var_dump($response->isSuccess());
        var_dump($response->getError());
        var_dump($response->getPrinter()->toArray());
        exit;
    }
    //获取非车产品列表
    if (1) {
//        $visitor = new NonCarProductListVisitor();
//        $visitor->argc['password'] = 'SCdlr@2022';
//        $visitor->argc['user'] = 'sichuan_dl';
//        $visitor->seats = '5';
//        $demo = $IDock->getBean($shortName);
//        $response = $demo->nonCarProductList($visitor);
//        var_dump($response->isSuccess());
//        var_dump($response->getError());
//        var_dump($response->getPrinter()->toArray());
//        exit;
        $visitor = new NonCarProductListVisitor();
        $visitor->argc['password'] = 'SCdlr@2022';
        $visitor->argc['user'] = 'sichuan_dl';
        $visitor->seats = '5';
        $demo = $IDock->getBean($shortName);
        $response = $demo->nonCarProductDetail($visitor);
        var_dump($response->isSuccess());
        var_dump($response->getError());
        var_dump($response->getPrinter()->toArray());
        exit;


    }
    //添加非车产品
    if (0) {
        $visitor = new NonCarInquiryVisitor();
        $single = new NonCarProductVisitor();
        $visitor->argc['orderNo'] = 'NSQQ202403051447461096';
        $single->productCode = '0201741';
        $single->planCode = '0003';
        $single->insuredNum = '1';
        $single->premium = '388';
        $visitor->nonCarListAppend($single);
        $demo = $IDock->getBean($shortName);
        $response = $demo->addNonCarOrder($visitor);
        var_dump($response->isSuccess());
        var_dump($response->getError());
        var_dump($response->getPrinter()->toArray());
        exit;
    }
    //
} catch (Exception $e) {
    var_dump("异常抛出：".$e->getFile()." ".$e->getLine().$e->getMessage());
}
